<?php /* SVN: $Id: $ */ ?>
<div class="blogViews index">
    <h2><?php echo __l('Update Views');?></h2>
    <?php if (!(isset($this->request->params['isAjax']) && $this->request->params['isAjax'] == 1)): ?>
            <?php echo $this->Form->create('BlogView' , array('type' => 'get', 'class' => 'normal','action' => 'index')); ?>
        	<div class="filter-section">
        		<div>
        			<?php echo $this->Form->input('q', array('label' => 'Keyword')); ?>
        		</div>
        		<div>
        			<?php echo $this->Form->submit(__l('Search'));?>
        		</div>
        	</div>
        	<?php echo $this->Form->end(); ?>
    <?php endif; ?>
    <?php echo $this->Form->create('BlogView' , array('class' => 'normal','action' => 'update')); ?>
    <?php echo $this->Form->input('r', array('type' => 'hidden', 'value' => $this->request->url)); ?>
    <?php echo $this->element('paging_counter');?>
<table class="list">
    <tr>
        <th><?php echo __l('Select'); ?></th>
        <th class="actions"><?php echo __l('Actions');?></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Blog'), 'Blog.name');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('User'), 'User.username');?></div></th>
		<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Ip'), 'Ip.ip');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Viewed on'), 'created');?></div></th>
    </tr>
<?php
if (!empty($blogViews)):
$i = 0;
foreach ($blogViews as $blogView):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
        <td><?php echo $this->Form->input('BlogView.'.$blogView['BlogView']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$blogView['BlogView']['id'], 'label' => false, 'class' => 'js-checkbox-list')); ?></td>
		<td class="actions dl"><span><?php echo $this->Html->link(__l('Delete'), array('action' => 'delete', $blogView['BlogView']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete')));?></span></td>
		<td><?php echo $this->Html->link($this->Html->cText($blogView['Blog']['title']), array('controller'=> 'blogs', 'action'=>'view', $blogView['Blog']['slug'], 'admin' => false), array('escape' => false));?></td>
		<td>
            <?php echo !empty($blogView['User']['username']) ? $this->Html->link($this->Html->cText($blogView['User']['username']), array('controller'=> 'users', 'action'=>'view', $blogView['User']['username'], 'admin' => false), array('escape' => false)) : __l('Guest');?>
        </td>
		<td class="dl">
                        <?php if(!empty($blogView['Ip']['ip'])): ?>							  
                            <?php echo  $this->Html->link($blogView['Ip']['ip'], array('controller' => 'users', 'action' => 'whois', $blogView['Ip']['ip'], 'admin' => false), array('target' => '_blank', 'title' => 'whois '.$blogView['Ip']['ip'], 'escape' => false));								
							?>
							<p>
							<?php 					
                            if(!empty($blogView['Ip']['Country'])):
                                ?>
                                <span class="flags flag-<?php echo strtolower($blogView['Ip']['Country']['iso2']); ?>" title ="<?php echo $blogView['Ip']['Country']['name']; ?>">
									<?php echo $blogView['Ip']['Country']['name']; ?>
								</span>
                                <?php
                            endif; 
							 if(!empty($blogView['Ip']['City'])):
                            ?>             
                            <span> 	<?php echo $blogView['Ip']['City']['name']; ?>    </span>
                            <?php endif; ?>
                            </p>
                        <?php else: ?>
							<?php echo __l('N/A'); ?>
						<?php endif; ?>    
		</td>
		<td><?php echo $this->Html->cDateTimeHighlight($blogView['BlogView']['created']);?></td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td colspan="6" class="notice"><?php echo __l('No Update Views available');?></td>
	</tr>
<?php
endif;
?>
</table>

<?php
if (!empty($blogViews)) :
    ?>
        <div>
            <?php echo __l('Select:'); ?>
            <?php echo $this->Html->link(__l('All'), '#', array('class' => 'js-admin-select-all','title' => __l('All'))); ?>
            <?php echo $this->Html->link(__l('None'), '#', array('class' => 'js-admin-select-none','title' => __l('None'))); ?>
        </div>
        <div class="admin-checkbox-button">
            <?php echo $this->Form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'label' => false, 'empty' => __l('-- More actions --'))); ?>
        </div>
        <div class="hide">
            <?php echo $this->Form->submit('Submit');  ?>
        </div>
        <div class="js-pagination">
            <?php echo $this->element('paging_links'); ?>
        </div>
        <?php
    endif;
    echo $this->Form->end();
    ?>
</div>